﻿@using FTBS.Models.Entities;
@model FTBS.Models.Entities.Film

@{
    ViewBag.Title = "Thay đổi thông tin";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}

<legend style="margin-top: 10px">Sửa thông tin phim</legend>

@using (Html.BeginForm("Edit", "Film", null, FormMethod.Post,
                              new { enctype = "multipart/form-data" }))
{
    @Html.ValidationSummary(true)
    @Html.HiddenFor(model => model.FilmId)
    @Html.HiddenFor(model => model.IsDeleted)

    <table class="table striped bordered hovered">
        <tr>
            <td style="padding: 0px 10px 0px 20px">
                <div style="font-weight: bold">
                    @Html.LabelFor(model => model.Name, "Tên phim")
                </div>
                <div class="input-control text">
                    @Html.EditorFor(model => model.Name)
                    <p style="color: red; font-size: 10pt">@Html.ValidationMessageFor(model => model.Name)</p>
                    @if (ViewBag.FilmName != null)
                    {
                        <p style="color: red; font-size: 10pt">Phim này đã tồn tại!</p>
                    }
                </div>
            </td>
            <td style="padding: 0px 10px 0px 20px">
                <div style="font-weight: bold">
                    @Html.LabelFor(model => model.Length, "Độ dài")
                </div>
                <div class="input-control text">
                    @Html.EditorFor(model => model.Length)
                    <p style="color: red; font-size: 10pt">@Html.ValidationMessageFor(model => model.Length)</p>
                </div>
            </td>
        </tr>
        <tr>
            <td style="padding: 0px 10px 0px 20px">
                <div style="font-weight: bold">
                    @Html.LabelFor(model => model.Nation, "Quốc gia")
                </div>
                <div class="input-control text">
                    @Html.EditorFor(model => model.Nation)
                    <p style="color: red; font-size: 10pt">@Html.ValidationMessageFor(model => model.Nation)</p>
                </div>
            </td>
            <td style="padding: 0px 10px 0px 20px">
                <div style="font-weight: bold">
                    @Html.LabelFor(model => model.Director, "Đạo diễn phim")
                </div>
                <div class="input-control text">
                    @Html.EditorFor(model => model.Director)
                    <p style="color: red; font-size: 10pt">@Html.ValidationMessageFor(model => model.Director)</p>
                </div>
            </td>
        </tr>
        <tr>
            <td style="padding: 0px 10px 0px 20px">
                <div style="font-weight: bold">
                    Lứa tuổi
                </div>
                <div class="input-control text">
                    @Html.EditorFor(model => model.AgeLimit)
                    <p style="color: red; font-size: 10pt">@Html.ValidationMessageFor(model => model.AgeLimit)</p>
                </div>
            </td>
            <td style="padding: 0px 10px 0px 20px">
                <div style="font-weight: bold">
                    Các diễn viên tham gia
                </div>
                <div class="input-control text">
                    @Html.EditorFor(model => model.Actor)
                    <p style="color: red; font-size: 10pt">@Html.ValidationMessageFor(model => model.Actor)</p>
                </div>
            </td>
        </tr>
        <tr>
            <td style="padding: 0px 10px 0px 20px">
                <div style="font-weight: bold">
                    Thể loại
                </div>
                <div class="input-control select">
                    <div>
                                    <select name="cate">
                            @foreach (var type in (List<Category>)ViewBag.CategoryId)
                            {
                                if (Model.CategoryId == type.CategoryId) 
                                {
                                    <option value="@type.CategoryId" selected>@type.CategoryName</option>
                                } else 
                                {
                                    <option value="@type.CategoryId">@type.CategoryName</option>
                                }
                            }
                        </select>
                    </div>
                </div>

            </td>
            <td style="padding: 0px 10px 0px 20px">
                <div style="font-weight: bold">
                    Định dạng
                </div>
                <div class="input-control text">
                    <div class="input-control select">
                        <div>
                              <select name="format">
                            @foreach (var type in (List<Format>)ViewBag.FormatId)
                            {
                                if (Model.FormatId == type.FormatId) 
                                {
                                    <option value="@type.FormatId" selected>@type.FormatName</option>
                                } else 
                                {
                                    <option value="@type.FormatId">@type.FormatName</option>
                                }
                            }
                        </select>
                        </div>
                    </div>
                </div>
            </td>
        </tr>
        <tr>
            <td style="padding: 0px 10px 0px 20px">
                <div style="font-weight: bold">
                    Miêu tả phim
                </div>
                <div class="input-control textarea">
                    @Html.TextAreaFor(model => model.Description)
                    <p style="color: red; font-size: 10pt">@Html.ValidationMessageFor(model => model.Description)</p>
                </div>
            </td>

            <td style="padding: 0px 10px 0px 20px">
                <div style="font-weight: bold">
                    @Html.LabelFor(model => model.Description, "Điểm IMDb")
                </div>
                <div class="input-control text">
                    @Html.EditorFor(model => model.IMDb)
                    <p style="color: red; font-size: 10pt">@Html.ValidationMessageFor(model => model.IMDb)</p>
                </div>
            </td>
        </tr>
        <tr>
            <td style="padding: 0px 10px 0px 20px" colspan="2">
                <div style="font-weight: bold">
                    @Html.LabelFor(model => model.ImageURL, "Hình đứng")
                </div>
                <div style="text-align: center">
                    <img src="~/Image/FilmImage/@Model.ImageURL" style="width:300px; height:300px"/>
                </div>
                <div class="input-control file info-state" data-role="input-control" style="margin-top: 20px">
                    <input id="ImagePath" title="Upload a product image" type="file" name="fileImage" />
                    <input type="text" id="__input_file_wrapper__" readonly="" style="z-index: 1; cursor: default;">
                    <button class="btn-file" type="button"></button>
                </div>
                <div class="input-control text" style="display: none;">
                    @Html.EditorFor(model => model.ImageURL)
                    <p style="color: red; font-size: 10pt">@Html.ValidationMessageFor(model => model.ImageURL)</p>
                </div>
            </td>
        </tr>
        <tr>
            <td style="padding: 0px 10px 0px 20px" colspan="2">
                <div style="font-weight: bold">
                    @Html.LabelFor(model => model.ImageURL, "Hình ngang")
                </div>
                <div style="text-align: center">
                    <img src="~/Image/FilmImage/Horizontal/@Model.ImageURL" style="width:500px; height:300px"/>
                </div>
                <div class="input-control file info-state" data-role="input-control" style="margin-top: 20px">
                    <input id="ImagePath" title="Upload a product image" type="file" name="fileImageHorizontal" />
                    <input type="text" id="__input_file_wrapper__" readonly="" style="z-index: 1; cursor: default;">
                    <button class="btn-file" type="button" name="submit"></button>
                </div>
                <p style="color: red; font-size: 10pt">@Html.ValidationMessageFor(model => model.ImageURL)</p>
            </td>
        </tr>
        <tr>
            <td style="padding: 0px 10px 0px 20px" colspan="2">
                <div style="font-weight: bold">
                    @Html.LabelFor(model => model.TrailerURL, "Trailer")
                </div>
                <div class="input-control text">
                    @Html.EditorFor(model => model.TrailerURL)
                    <p style="color: red; font-size: 10pt">@Html.ValidationMessageFor(model => model.TrailerURL)</p>
                </div>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <input class="button info" type="submit" value="Lưu" style="width: 77px;text-align: center"/>
                 <button class="button danger" style="float: right">
                    @Html.ActionLink("Quay lại", "Index")
                </button>
            </td>
        </tr>
    </table>           
}



